﻿Imports ValorYReferencia.Personas
Namespace Facturacion
    Public Class Cliente
        Inherits Persona

        Private _facturas As List(Of Factura) = New List(Of Factura)
        Public Property Facturas() As List(Of Factura)
            Get
                Return _facturas
            End Get
            Set(ByVal value As List(Of Factura))
                _facturas = value
            End Set
        End Property

        Public Function ObtenerConsumoHistorico() As Double
            Dim total As Double = 0
            For Each Factura In Facturas
                total += Factura.ObtenerTotal()
            Next
            Return total
        End Function

        Public Function ObtenerConsumoDeFacturas(ByVal predicado As Predicate(Of Factura)) As Double
            Dim total As Double = 0
            For Each Factura In Facturas
                If (predicado(Factura)) Then
                    total += Factura.ObtenerTotal()
                End If
            Next
            Return total
        End Function
    End Class
End Namespace
